﻿using System.Collections;
using System.Collections.Generic;
using System.Windows;

namespace VNet.VisiSuite.Controls
{
    public partial class MetroIconMenu
    {
        public MetroIconMenu()
        {
            InitializeComponent();
            _menu.DataContext = this;
        }

        public IList<VNetMenuItem> Icons
        {
            get { return (IList<VNetMenuItem>)GetValue(IconsProperty); }
            set { SetValue(IconsProperty, value); }
        }

        // Using a DependencyProperty as the backing store for Icons.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty IconsProperty = DependencyProperty.Register("Icons", typeof(IList<VNetMenuItem>), typeof(MetroIconMenu)
            , new FrameworkPropertyMetadata(null, IconsChangedCallback));

        private static void IconsChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var menu = d as MetroIconMenu;
            menu._menu.ItemsSource = (IList<VNetMenuItem>)e.NewValue;
            menu._menu.Items.Refresh();
        }

        public int Count()
        {
            return _menu.Items != null ? _menu.Items.Count : 0;
        }
    }
}